Code sample Home

Add fillet arc between two lines
void DemoFillet2 (HANDLE hLcWnd)
{
  HANDLE hDrw, hBlock, hArc, hLine1, hLine2, hText;
  double L1x0, L1y0, L1x1, L1y1, L2x0, L2y0, L2x1, L2y1;
  double Rad, Bis, Tang, Xs, Ys, Xm, Ym, Xe, Ye, X, Y, Ht;
  int    iPnt;
  bool   bCorrectLines;
  WCHAR  szText[8];

  // get a drawing and block, linked with CAD window
  hDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );
  hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_VIEWBLOCK );

  // first line
  L1x0 = 10.0;
  L1y0 = 0.0;
  L1x1 = 23.0;
  L1y1 = 22.0;

  // second line
  L2x0 = 48.0;
  L2y0 = 10.0;
  L2x1 = 60.0;
  L2y1 = 0.0;

  hLine1 = lcBlockAddLine( hBlock, L1x0, L1y0, L1x1, L1y1 );
  hLine2 = lcBlockAddLine( hBlock, L2x0, L2y0, L2x1, L2y1 );
  if (lcFilletSetLines( L1x0, L1y0, L1x1, L1y1, L2x0, L2y0, L2x1, L2y1 ) == TRUE){
    // one of the 3 parameters must be set
    Rad = 0.0;    // arc's radius
    Bis = 10.0;   // bisector length
    Tang = 0.0;   // tangent length
    if (lcFillet( Rad, Bis, Tang ) == TRUE){
      // get start-point of fillet arc
      if (lcFilletGetPoint( 1, &Xs, &Ys ) == TRUE){
        // get middle-point of fillet arc
        if (lcFilletGetPoint( 2, &Xm, &Ym ) == TRUE){
          // get end-point of fillet arc
          if (lcFilletGetPoint( 3, &Xe, &Ye ) == TRUE){
            // add fillet arc
            hArc = lcBlockAddArc3P( hBlock, Xs, Ys, Xm, Ym, Xe, Ye );
            // set color of the arc
            lcPropPutInt( hArc, LC_PROP_ENT_COLORI, 1 );
          }
        }
      }

      Ht = -1.0;  // height of text, negative value means pixels, -1 means default GUI text size
      // set active color
      lcPropPutInt( hDrw, LC_PROP_DRW_COLORI, 2 );
      // get all points
      for (iPnt=0; iPnt<=6; ++iPnt){
        if (lcFilletGetPoint( iPnt, &X, &Y ) == TRUE){
          lcBlockAddPoint2( hBlock, X, Y, LC_POINT_PIXEL|LC_POINT_CIRCLE, -0.5 );
          // add text - index of the point
          _itow( iPnt, szText, 10 );
          hText = lcBlockAddText2( hBlock, szText, X, Y, LC_TA_LEFTOP, Ht, 1.0, 0.0, 0.0 );
          // define text offset (in pixels)
          lcPropPutInt( hText, LC_PROP_TEXT_DX, 4 );
          lcPropPutInt( hText, LC_PROP_TEXT_DY, -4 );
        }
      }
     
      bCorrectLines = false; // set true if you want to correct lines hLine1, hLine2
      if (bCorrectLines){
        lcFilletGetPoint( 0, &L1x0, &L1y0 );
        lcPropPutFloat( hLine1, LC_PROP_LINE_X0, L1x0 );
        lcPropPutFloat( hLine1, LC_PROP_LINE_Y0, L1y0 );
        lcPropPutFloat( hLine1, LC_PROP_LINE_X1, Xs );
        lcPropPutFloat( hLine1, LC_PROP_LINE_Y1, Ys );
        lcFilletGetPoint( 4, &L2x1, &L2y1 );
        lcPropPutFloat( hLine2, LC_PROP_LINE_X0, Xe );
        lcPropPutFloat( hLine2, LC_PROP_LINE_Y0, Ye );
        lcPropPutFloat( hLine2, LC_PROP_LINE_X1, L2x1 );
        lcPropPutFloat( hLine2, LC_PROP_LINE_Y1, L2y1);
      }
    }
  }
  lcWndExeCommand( hLcWnd, LC_CMD_ZOOM_EXT, 0 );
}

This will create a drawing as shown on the picture below:

bCorrectLines = false;


bCorrectLines = true;